package com.neuedu.service.impl;

import com.neuedu.dao.DeptClassityDao;
import com.neuedu.dao.DeptTypeDao;
import com.neuedu.factory.ClassFactory;
import com.neuedu.service.DeptTypeService;

import java.util.List;
import java.util.Map;

public class DeptTypeServiceImpl implements DeptTypeService {
    @Override
    public List<Map<String, Object>> getAllDeptDeptType() {
        DeptTypeDao dtd = (DeptTypeDao) ClassFactory.createObj("DeptTypeDao");
        String sql = "SELECT * FROM depttype;";
        return dtd.getAllDeptType(sql);
    }

    @Override
    public int deltype(Object[] objs) {
        DeptTypeDao dcd = (DeptTypeDao) ClassFactory.createObj("DeptTypeDao");
        int flag = dcd.delclassify(objs);
        return flag;
    }

    @Override
    public int addType(Object[] objs) {
        DeptTypeDao dcd = (DeptTypeDao) ClassFactory.createObj("DeptTypeDao");
        return dcd.addClassify(objs);
    }

    @Override
    public int updateType(Object[] objs) {
        DeptTypeDao dcd = (DeptTypeDao) ClassFactory.createObj("DeptTypeDao");
        return dcd.updateClassify(objs);
    }

    @Override
    public List<Map<String, Object>> likeQuery(Object[] objs) {
        DeptTypeDao dcd = (DeptTypeDao) ClassFactory.createObj("DeptTypeDao");
        String sql = "SELECT * FROM depttype where typename like ? OR id like ?";
        return dcd.getLikeDeptClassity(sql, objs);
    }
}
